<!--
  * 流程设计
  *
  * @Author:    ADog
  * @Date:      2025-10-06 20:16:41
  * @Copyright  1.0
-->
<template>
  <!---------- 查询表单form begin ----------->
  <a-form class="smart-query-form">
    <a-row class="smart-query-form-row">
      <a-form-item label="流程模型名称" class="smart-query-form-item">
        <a-input style="width: 200px" v-model:value="queryForm.name" placeholder="流程模型名称" />
      </a-form-item>
      <a-form-item class="smart-query-form-item">
        <a-button type="primary" @click="onSearch">
          <template #icon>
            <SearchOutlined />
          </template>
          查询
        </a-button>
        <a-button @click="resetQuery" class="smart-margin-left10">
          <template #icon>
            <ReloadOutlined />
          </template>
          重置
        </a-button>
      </a-form-item>
    </a-row>
  </a-form>

  <a-card size="small" :bordered="false" :hoverable="true">
  <!---------- 查询表单form end ----------->

    <!---------- 表格操作行 end ----------->
  <!---------- 表格 begin ----------->
  <a-table
    size="small"
    :scroll="{ y: 800 }"
    :dataSource="tableData"
    :columns="columns"
    rowKey="id"
    bordered
    :loading="tableLoading"
    :pagination="false"
  >
    <template #bodyCell="{   column }">


      <template v-if="column.dataIndex === 'action'">
        <div class="smart-table-operate">
        </div>
      </template>
    </template>
  </a-table>
    <!---------- 表格 end ----------->

    <div class="smart-query-table-page">
      <a-pagination
        showSizeChanger
        showQuickJumper
        show-less-items
        :pageSizeOptions="PAGE_SIZE_OPTIONS"
        :defaultPageSize="queryForm.pageSize"
        v-model:current="queryForm.pageNum"
        v-model:pageSize="queryForm.pageSize"
        :total="total"
        @change="queryData"
        @showSizeChange="queryData"
        :show-total="(total) => `共${total}条`"
      />
    </div>

</a-card>
</template>
<script setup>
import { reactive, ref, onMounted } from 'vue';
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
import { smartSentry } from '/@/lib/smart-sentry';
import {flowDeployApi} from '/@/api/business/flowDeploy/flow-deploy-api.js';

// ---------------------------- 表格列 ----------------------------

const columns = ref([
  {
    title: '部署信息编号',
    dataIndex: 'id',
    ellipsis: true,
  },
  {
    title: '流程模型key',
    dataIndex: 'key',
    ellipsis: true,
  },
  {
    title: '部署流程名称',
    dataIndex: 'name',
    ellipsis: true,
  },
  {
    title: '创建时间',
    dataIndex: 'created',
    ellipsis: true,
  },
  {
    title: '最后更新人',
    dataIndex: 'lastUpdatedBy',
    ellipsis: true,
  },
  {
    title: '部署时间',
    dataIndex: 'deployTime',
    ellipsis: true,
  },
  {
    title: '操作',
    dataIndex: 'action',
    fixed: 'right',
    width: 90,
  },
]);

// ---------------------------- 查询数据表单和方法 ----------------------------

const queryFormState = {
  name: undefined, //流程模型名称
  pageNum: 1,
  pageSize: 10,
};
// 查询表单form
const queryForm = reactive({ ...queryFormState });
// 表格加载loading
const tableLoading = ref(false);
// 表格数据
const tableData = ref([]);
// 总数
const total = ref(0);


// 查询数据
async function queryData() {
  tableLoading.value = true;
  try {
    let queryResult = await flowDeployApi.queryPage(queryForm);
    tableData.value = queryResult.data.list;
    total.value = queryResult.data.total;
  } catch (e) {
    smartSentry.captureError(e);
  } finally {
    tableLoading.value = false;
  }
}



onMounted(queryData);



</script>

